package com.ruoyi.web.area.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.area.domain.Continents;
import com.ruoyi.web.area.service.IContinentsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 大洲管理Controller
 * 
 * @author hjy
 * @date 2022-12-10
 */
@RestController
@RequestMapping("/area/continents")
public class ContinentsController extends BaseController
{
    @Autowired
    private IContinentsService continentsService;

    /**
     * 查询大洲管理列表
     */
    @PreAuthorize("@ss.hasPermi('area:continents:list')")
    @GetMapping("/list")
    public TableDataInfo list(Continents continents)
    {
        startPage();
        List<Continents> list = continentsService.selectContinentsList(continents);
        return getDataTable(list);
    }

    /**
     * 导出大洲管理列表
     */
    @PreAuthorize("@ss.hasPermi('area:continents:export')")
    @Log(title = "大洲管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Continents continents)
    {
        List<Continents> list = continentsService.selectContinentsList(continents);
        ExcelUtil<Continents> util = new ExcelUtil<Continents>(Continents.class);
        util.exportExcel(response, list, "大洲管理数据");
    }

    /**
     * 获取大洲管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('area:continents:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(continentsService.selectContinentsById(id));
    }

    /**
     * 新增大洲管理
     */
    @PreAuthorize("@ss.hasPermi('area:continents:add')")
    @Log(title = "大洲管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Continents continents)
    {
        return toAjax(continentsService.insertContinents(continents));
    }

    /**
     * 修改大洲管理
     */
    @PreAuthorize("@ss.hasPermi('area:continents:edit')")
    @Log(title = "大洲管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Continents continents)
    {
        return toAjax(continentsService.updateContinents(continents));
    }

    /**
     * 删除大洲管理
     */
    @PreAuthorize("@ss.hasPermi('area:continents:remove')")
    @Log(title = "大洲管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(continentsService.deleteContinentsByIds(ids));
    }
}
